import http from '../utils/request'

// 登录接口
export const login = (username, password) => {
    return http.post("/api/user/login", { username, password })
}

// 注册接口
export const register = (username, password, sex) => {
    return http.post("/api/user/register", { username, password, sex })
}

// 根据id修改用户信息
export const updateUserById = (params) =>
    http({
        'url': "/api/user/updateById",
        'method': 'PUT',
        'data': params
    })

// 根据id查询用户
export const selectUserById = (id) => {
    // 使用模板字符串+${}传递restful风格的参数
    return http.get(`/api/user/selectUserById/${id}`)
}

// 新增用户
export const addUser = (data) =>
    http({
        'url': `/api/user/addUser/${data.ids}`,
        'method': 'post',
        'data': data
    })

// 查询权限信息
export const selectMenu = () =>
    http({
        'url': '/api/user/menus',
        'method': 'get'
    })

// 分页查询
export const getUserList = (params) =>
    http({
        'url': '/api/user/page',
        'method': 'get',
        'params': params
    })

// 根据id删除用户信息
export const deleteUserById = (params) =>
    http({
        'url': '/api/user/deleteUserById',
        'method': 'delete',
        'params': { id: params.id }
    })


// 查询各职位及人数
export const selectJobAndCount = () => {
    return http.get("/api/user/selectJobAndCount")
}

// 为用户授权
export const authorization = (id, authId) => {
    return http.put(`/api/user/authorization/${id}/${authId}`)
}
// 查询权限列表
export const getAuth = () => {
    return http.get("/api/user/getAuth")
}